#ifdef WX_PRECOMP
#include "../wx_pch.h"
#else
#include <wx/wx.h>
#endif //WX_PRECOMP

#include "race_utility.h"
#include "../race_item.h"

namespace
{
  const wxString RaceBonusItems[] =
  {
    _("Spaceships speed and range"),
    _("Defense systems"),
    _("Prices"),
    _("Civil production speed"),
    _("Military production speed"),
    _("Units and buildings HP"),
    _("Damage"),
    _("Stealth bonus"),
    _("Stealth detection")
  };
}

size_t RaceUtility::GetBonusCount()
{
  return sizeof(RaceBonusItems) / sizeof(RaceBonusItems[0]);
}

wxString RaceUtility::GetBonusName(size_t index)
{
  if (index >= GetBonusCount())
  {
    return wxEmptyString;
  }
  return wxGetTranslation(RaceBonusItems[index]);
}

double RaceUtility::GetBonusValue(size_t index, const RaceItem& raceItem)
{
  if (index >= GetBonusCount())
  {
    wxASSERT(!wxT("Bonus index is too large."));
    return 0.0;
  }

  switch (index)
  {
  case 0: return raceItem.BonusSpeed;
  case 1: return raceItem.BonusDefence;
  case 2: return raceItem.BonusPrice;
  case 3: return raceItem.BonusCivilProduction;
  case 4: return raceItem.BonusMilitaryProduction;
  case 5: return raceItem.BonusHitPoints;
  case 6: return raceItem.BonusDamage;
  case 7: return raceItem.BonusStealth;
  case 8: return raceItem.BonusDetection;
  default: break;
  }

  wxASSERT(!wxT("Unknown field"));
  return 0.0;
}
